#!/usr/bin/env python
# -*- coding:utf8 -*-
# uncompyle6 version 2.15.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.10 (default, Jul  1 2017, 13:36:56) 
# [GCC 4.4.6 20110731 (Red Hat 4.4.6-4)]
# Embedded file name: ./esb/components/bk/apis/bk_paas/get_app_info.py
# Compiled at: 2017-11-16 15:44:28
"""
Copyright © 2012-2017 Tencent BlueKing. All Rights Reserved. 蓝鲸智云 版权所有
"""
from common.forms import BaseComponentForm, ListField
from common.constants import API_TYPE_Q
from components.component import Component
from .toolkit import configs

class GetAppInfo(Component):
    """
    apiLabel 获取应用信息
    apiMethod GET
    
    ### 功能描述
    
    获取应用信息
    
    ### 请求参数
    
    {{ common_args_desc }}
    
    #### 接口参数
    
    | 字段      |  类型      | 必选   |  描述      |
    |-----------|------------|--------|------------|
    | target_app_code |  string    | 否     | 目标蓝鲸应用ID，多个以英文逗号分隔，为空则表示所有应用 |
    
    ### 请求参数示例
    
    ```python
    {
        "app_code": "esb_test",
        "app_secret": "xxx",
        "bk_token": "xxx",
        "target_app_code": "bk_test,esb_test",
    }
    ```
    ### 返回结果示例
    ```python
    {
        "result": true,
        "code": "00",
        "message": "",
        "data": [
            {
                "app_code": "bk_test",
                "app_name": "BKTest"
            },
            {
                "app_code": "esb_test",
                "app_name": "ESBTest"
            }
        ]
    }
    ```
    """
    sys_name = configs.SYSTEM_NAME
    api_type = API_TYPE_Q

    class Form(BaseComponentForm):
        target_app_code = ListField(label=u'目标蓝鲸应用ID', required=False)

        def clean(self):
            return {'target_app_code': (';').join(self.cleaned_data['target_app_code'])
               }

    def handle(self):
        self.response.payload = self.outgoing.http_client.get(configs.host, '/paas/api/app_info/', params=self.form_data, headers=configs.headers)
